package com.seeqool.v1.chartframes;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.plot.PlotOrientation;

import com.seeqool.v1.datamodel.SQLTable;
import com.seeqool.v1.dataviews.FlippedCategoryView;

public class BarChartFrame extends BaseChartFrame {

	private static final long serialVersionUID = 1L;

	public BarChartFrame(SQLTable queryResult, int majorAxis, Integer[] minorAxes) {
		super("Bar Chart");
		FlippedCategoryView data = new FlippedCategoryView(queryResult, majorAxis, minorAxes, true);
		if (minorAxes.length==1) {
			this.addContent(new ChartPanel(ChartFactory.createStackedBarChart(null, data.getTitle(), (String) data.getRowKey(0), data, PlotOrientation.HORIZONTAL, false, true, false)));
		} else {
			this.addContent(new ChartPanel(ChartFactory.createStackedBarChart(null, data.getTitle(), null, data, PlotOrientation.HORIZONTAL, true,  true, false)));
		}
	}
}
